Skip to content

Comments

Fix #13944 FN constParameterPointer in method in derived class#8240

Open
ceJce wants to merge 4 commits intodanmar:mainfrom
ceJce:fix13944_fp_constparameterpointer
Open

Fix #13944 FN constParameterPointer in method in derived class#8240
ceJce wants to merge 4 commits intodanmar:mainfrom
ceJce:fix13944_fp_constparameterpointer

Conversation

@ceJce
Copy link
Contributor

@ceJce ceJce commented Feb 19, 2026

class C : public QObject
{
public:
void func01(QPoint* pt) { // <- pt can be const
if (nullptr == pt) {}
}
};

The fix adds inconclusive warning for this case, including tests.

@chrchr-github
Copy link
Collaborator

IMHO we should follow the approach used for https://trac.cppcheck.net/ticket/13282
"Either there is a missing override, or the parameter 'x' can be const."
Just making the warning inconclusive tells the user nothing.

@ceJce
Copy link
Contributor Author

ceJce commented Feb 19, 2026

IMHO we should follow the approach used for https://trac.cppcheck.net/ticket/13282 "Either there is a missing override, or the parameter 'x' can be const." Just making the warning inconclusive tells the user nothing.

Can you clarify what you object of? The inconclusion part or the warning?

Before it was no warning at all, now there is but inconclusive is added since the check failed to find the base class. The inconclusion part was suggested by Daniel M.

if (foundAllBaseClasses) //If we've seen all the base classes and none of the above were true then it must not be virtual
return false;
return defaultVal; //If we can't see all the bases classes then we can't say conclusively
//If we can't see all the bases classes then we can't say conclusively, set inconclusive (if possible) and return default value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't inconclusive redundant since there is pFoundAllBaseClasses already?

@chrchr-github
Copy link
Collaborator

IMHO we should follow the approach used for https://trac.cppcheck.net/ticket/13282 "Either there is a missing override, or the parameter 'x' can be const." Just making the warning inconclusive tells the user nothing.

Can you clarify what you object of? The inconclusion part or the warning?

Before it was no warning at all, now there is but inconclusive is added since the check failed to find the base class. The inconclusion part was suggested by Daniel M.

The warning should have the "either ... or" format, and be inconclusive.

@danmar
Copy link
Owner

danmar commented Feb 19, 2026

I agree the warning message can be clarified and it would be good to be somewhat consistent..

@ceJce ceJce force-pushed the fix13944_fp_constparameterpointer branch from a5a7044 to 04b4e37 Compare February 20, 2026 08:26
@chrchr-github chrchr-github changed the title Fix #13944 fn constparameterpointer Fix #13944 FN constParameterPointer in method in derived class Feb 20, 2026
Add inconclusive and default=false (instead of true) in checkConstPointer.
@ceJce ceJce force-pushed the fix13944_fp_constparameterpointer branch from 04b4e37 to 81ef7f1 Compare February 20, 2026 11:40
Changed so that error message is in format "either ... or can be const" format.
Added testcase with override, i.e. no warning.
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants